<template>
    <div class="square-description">
        <h1>Connect your store and start selling on Squarespace</h1>
        <h2>
            <figure>
                <img src="https://img.podpartner.com/static/images-20230202/square-description-banner.png" />
            </figure>
        </h2>

        <h3>Connect your store and start selling on Squarespace</h3>
        <p>
            1. Click the <em>"Connect to Squarespace"</em> button below to enter the
            Squarespace platform <br />
            <button @click="linkToStore()">Connect to Squarespace</button>
            2. You need to log in to your Squarespace account first. After that, Click
            on <em>"ALLOW"</em> to proceed with the integration.
        </p>
        <p>
            <img src="https://img.podpartner.com/static/images-20230202/square-description-content.png" />
        </p>

        <h4>
            That's it. You're done! Now you can add products to your Squarespace store.
        </h4>
    </div>
</template>
<script>
import { mapGetters, mapState } from "vuex";
export default {
    name: "SquareDescription",
    layout: "default",
    data () {
        return {};
    },
    computed: {
        ...mapGetters({
            logined: "getIsLogin",
        }),
    },
    methods: {
        async getLink () {
            let opener = window.open("about:blank");
            let response = await this.$http("AppStore.getSquareSpaceConnectUrl");

            if (response.code === 0) {
                opener && (opener.location = response.data);
            } else {
                this.$uxMessage.error(
                    response.msg || "get connect url failure"
                );
                opener && opener.close();
            }
        },

        linkToStore () {
            if (this.logined) {
                this.getLink();
            } else {
                this.$emit("global:userLogin", (e) => {
                    this.getLink()
                    // 登录完成
                });
            }
        },
    },
};
</script>
<style lang="scss" scoped>
.square-description {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding-top: 72px;
    padding-bottom: 140px;

    h1 {
        text-align: center;
        font-size: 36px;
        font-family: Roboto-Medium, Roboto;
        font-weight: 500;
        color: #000000;
        line-height: 46px;
    }

    h2 {
        margin-top: 32px;
        position: relative;
        figure {
            position: relative;
            overflow: hidden;
        }
        img {
            width: 100%;
        }
    }

    h3 {
        font-size: 24px;
        font-family: Roboto-Medium, Roboto;
        font-weight: 400;
        color: #000000;
        line-height: 32px;
        margin-top: 36px;
    }

    p {
        margin-top: 18px;
        font-size: 16px;

        color: #555555;
        line-height: 30px;

        & > button {
            display: block;
            margin: 10px 0 18px;
            padding: 0 18px;
            // width: 140px;
            height: 38px;
            background: #ea4c89;
            border-radius: 6px;
            font-size: 14px;

            font-weight: normal;
            color: #ffffff;
            border: none;

            &:hover {
                background-color: #c94175;
            }
        }

        em {
            color: #000;
            font-family: Roboto-Medium, Roboto;
            font-weight: 400;
        }

        img {
            border: 1px solid #f0f0f0;
            border-radius: 5px;
        }
    }

    h4 {
        font-size: 18px;
        font-family: Roboto-Medium, Roboto;
        font-weight: 400;
        color: #000000;
        line-height: 32px;
        margin-top: 38px;
    }

    h6 {
        position: relative;
        margin-top: 38px;
        max-width: 850px;
        background: #f9f3e0;
        border-radius: 4px;
        box-sizing: border-box;
        padding: 24px 28px 24px 52px;
        font-weight: normal;
        font-size: 16px;

        color: #000000;
        line-height: 22px;

        i {
            left: 28px;
            top: 24px;
            width: 24px;
            height: 24px;
            color: #e4b23d;
            position: absolute;
        }
    }
}
@media (max-width: 960px) {
    .square-description {
        max-width: 500px;
        box-sizing: border-box;
        padding: 18px 14px 32px;
        h1 {
            width: calc(100% - 40px);
            font-size: 16px;
            font-weight: bold;
            line-height: 18px;
        }
        h2 {
            margin-top: 14px;
            button {
                display: none;
            }
        }
        h3 {
            margin-top: 16px;
        }
        p {
            &:nth-child(4) {
                margin-top: 6px;
                font-size: 14px;
                font-weight: 400;
                color: #555555;
                line-height: 20px;
                em {
                    font-size: 15px;
                    font-weight: 400;
                    color: #000;
                }
                button {
                    margin: 14px 0 16px;
                }
            }
            &:nth-child(5) {
                margin-top: 16px;
                img {
                    width: 100%;
                }
            }
        }
        h4 {
            margin-top: 24px;
            font-size: 16px;
            font-weight: bold;
            color: #000000;
            line-height: 18px;
        }
        h6 {
            margin-top: 24px;
            padding: 14px 12px 14px 36px;
            font-size: 14px;
            font-weight: 400;
            color: #000000;
            line-height: 20px;
            i {
                left: 14px;
                top: 16px;
                width: 16px;
                height: 16px;
                font-size: 16px;
                line-height: 16px;
            }
        }
    }
}
</style>
